# -*- coding: utf-8 -*-
# @Time    : 2019-01-16 20:02
# @Author  : jerry
# @FileName: route.py
# @Software: PyCharm Professional Edition
# @Version : python 3.6.2
from flask import render_template

from master import session
from master.models.sys_models import MyTest
from master.run import app


@app.route("/")
def home():
    return render_template('index.html')


@app.route("/test", methods=['GET', 'POST'])
def test():
    first = MyTest(name='jerry', age=38)
    session.add(first)
    session.commit()
    return 'success'


@app.route("/test/<userName>", methods=['GET', 'POST'])
def test_query(userName):
    if userName is None:
        return 'failed'
    else:
        first = MyTest.query.filter_by(name=userName).first()
        return str(first.id)


